package com.advantage.autentication;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import com.advantage.MainActivity;

/**
 * Created by hirsche on 17/04/2014.
 */
public class LogoutActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LogoutAsyncTask task = new LogoutAsyncTask(this);
        task.execute();
    }

    private class LogoutAsyncTask extends AsyncTask<String, Void, Void> {
        ProgressDialog pd;
        Context co;

        public LogoutAsyncTask (Context co){
            this.co = co;
            pd = ProgressDialog.show(co, "Logging out", "Please wait...", true);
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            this.pd.show();
        }
        @Override
        protected Void doInBackground(String... params) {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            pd.dismiss();
            Intent intent = new Intent(co, LoginActivity.class);
            startActivity(intent);

        }
    }

}
